//
//  WeatherReportModel.swift
//  WeatherReport
//
//  Created by AndreaArlex on 16/1/30.
//  Copyright © 2016年 AndreaArlex. All rights reserved.
//

import UIKit
import ObjectMapper

class WeatherReportModel: Mappable {

    var basic : Basic? //城市基本信息
    var aqi   : Aqi? // 空气质量指数
    var daily_forecast  : Array<DailyWeather>? //天气预报
    var hourly_forecast : Array<HourWeather>? //每小时天气预报
    var suggestion      : WeatherSuggestion? //建议
    
    required init?(_ map: Map){
        
        
    }
    
    func mapping(map: Map) {
        
        basic <- map["basic"]
        aqi <- map["aqi"]
        daily_forecast  <- map["daily_forecast"]
        hourly_forecast <- map["hourly_forecast"]
        suggestion      <- map["suggestion"]
    }
    
}

 /// basic 城市基本信息
class Basic: Mappable {
    
    var city : NSString? //城市名称
    var id   : NSString? //城市ID
    var cnty : NSString? //国家名称
    var lat  : NSString? //纬度
    var lon  : NSString? //经度
    var update : Update? //更新时间
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
        
        city   <- map["city"]
        id     <- map["id"]
        cnty   <- map["cnty"]
        lat    <- map["lat"]
        lon    <- map["lon"]
        update <- map["update"]
    }
}

/// aqi 空气质量指数
class Aqi: Mappable {
    
    var city : City? //城市数据
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
        
        city    <- map["city"]
    }
}

/**
*  @author AndreaArlex, 16-02-01 10:02:22
*
*  基础类
*/

/// 更新时间
class Update: Mappable {
    
    var loc : NSString? //数据更新的当地时间
    var utc : NSString? //数据更新的UTC时间
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
        
        loc <- map["loc"]
        utc <- map["utc"]
    }
}

/// 城市数据
class City: Mappable {
    
    var aqi  : NSString? //空气质量指数
    var co   : NSString? //一氧化碳1小时平均值(ug/m³)
    var no2  : NSString? //二氧化氮1小时平均值(ug/m³)
    var o3   : NSString? //二氧化硫1小时平均值(ug/m³)
    var pm10 : NSString? //PM10 1小时平均值(ug/m³)
    var pm25 : NSString? //PM2.5 1小时平均值(ug/m³)
    var qlty : NSString? //臭氧1小时平均值(ug/m³)
    var so2  : NSString? //空气质量类别
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
        
        aqi  <- map["aqi"]
        co   <- map["co"]
        no2  <- map["no2"]
        o3   <- map["o3"]
        pm10 <- map["pm10"]
        pm25 <- map["pm25"]
        qlty <- map["qlty"]
        so2  <- map["so2"]
    }
}

/// 每天的天气情况
class DailyWeather: Mappable {
    
    var astro : Astro? //日出日落
    var cond  : Cond? //天气状况
    var date  : NSDate? //当地日期
    var hum   : NSString? //湿度(%)
    var pcpn  : NSString? //降雨量(mm)
    var pop   : NSString? //降水概率
    var pres  : NSString? //气压
    var vis   : NSString? //能见度(km)
    var tmp   : Tmp?  //温度
    var wind  : Wind? //风力状况
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
    
        astro <- map["astro"]
        cond  <- map["cond"]
        date  <- (map["date"],DateTransform())
        hum   <- map["hum"]
        pcpn  <- map["pcpn"]
        pop   <- map["pop"]
        pres  <- map["pres"]
        vis   <- map["vis"]
        tmp   <- map["tmp"]
        wind  <- map["wind"]
    }
}

/// 每小时天气
class HourWeather: Mappable {
    
    var date  : NSDate? //当地日期和时间
    var hum   : NSString? //湿度(%)
    var pop   : NSString? //降水概率
    var pres  : NSString? //气压
    var tmp   : NSString? //温度
    var wind  : Wind? //风力状况
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
    
        date  <- map["date"]
        hum   <- map["hum"]
        pop   <- map["pop"]
        pres  <- map["pres"]
        tmp   <- map["tmp"]
        wind  <- map["wind"]
    }
}

/// 现在的天气
class NowWeather: Mappable {
    
    var cond  : NowCond? //现在的天气状况
    var fl    : NSString? //体感温度
    var hum   : NSString? //湿度(%)
    var pcpn  : NSString? //降雨量(mm)
    var pop   : NSString? //降水概率
    var pres  : NSString? //气压
    var vis   : NSString? //能见度(km)
    var tmp   : Tmp?  //温度
    var wind  : Wind? //风力状况
    
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
    
        cond  <- map["cond"]
        fl    <- map["fl"]
        hum   <- map["hum"]
        pcpn  <- map["pcpn"]
        pop   <- map["pop"]
        pres  <- map["pres"]
        vis   <- map["vis"]
        tmp   <- map["tmp"]
        wind  <- map["wind"]
    }
}

/// 建议
class WeatherSuggestion: Mappable {
    
    var comf  : Suggestion?
    var cw    : Suggestion? //洗车指数
    var drsg  : Suggestion? //穿衣指数
    var flu   : Suggestion? //感冒指数
    var sport : Suggestion? //运动指数
    var trav  : Suggestion? //旅游指数
    var uv    : Suggestion? //紫外线指数
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
    
        comf  <- map["comf"]
        cw    <- map["cw"]
        drsg  <- map["drsg"]
        flu   <- map["flu"]
        sport <- map["sport"]
        trav  <- map["trav"]
        uv    <- map["uv"]
    }
}

/// 日出日落
class Astro: Mappable {
    
    var sr : NSString? //日出时间
    var ss : NSString? //日落时间
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
    
        sr  <- map["sr"]
        ss  <- map["ss"]
    }
}

/// 天气状况
class Cond: Mappable {
    
    var code_d : NSString? //白天天气代码
    var code_n : NSString? //夜间天气代码
    var txt_d  : NSString? //白天天气描述
    var txt_n  : NSString? //夜间天气描述
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
    
        code_d  <- map["code_d"]
        code_n  <- map["code_n"]
        txt_d   <- map["txt_d"]
        txt_n   <- map["txt_n"]
    }
}

/// 现在的天气状况
class NowCond: Mappable {
    
    var code : NSString? //天气代码
    var txt  : NSString? //天气描述
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
    
        code <- map["code"]
        txt  <- map["txt"]
    }
}

/// 温度
class Tmp: Mappable {
    
    var max : NSString? //最高温度(摄氏度)
    var min : NSString? //最低温度(摄氏度)
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
        
        max  <- map["max"]
        min  <- map["min"]
    }
}

/// 风力状况
class Wind: Mappable {
    
    var deg : NSString? //风向(角度)
    var dir : NSString? //风向(方向)
    var sc  : NSString? //风力等级
    var spd : NSString? //风速(Kmph)
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
        
        deg  <- map["deg"]
        dir  <- map["dir"]
        sc   <- map["sc"]
        spd  <- map["spd"]
    }
}

/// 建议
class Suggestion: Mappable {
    
    var brf : NSString? //简介
    var txt : NSString? //详情
    
    required init?(_ map: Map){
        
    }
    
    func mapping(map: Map) {
    
        brf <- map["brf"]
        txt <- map["txt"]
    }
}